home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / File / c / AllocLoad next >
Text File  |  1995-08-29  |  1KB  |  44 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    File.AllocLoad.c
  12.     Author:  Copyright © 1995 Julian Smith
  13.     Version: 1.01 (22 Jul 1995)
  14.     Mods:    Changed name from File_AllocLoad to File_AllocLoad0
  15. */
  16.  
  17. #include <stdlib.h>
  18.  
  19. #include "DeskLib:File.h"
  20.  
  21.  
  22. char    *File_AllocLoad0( char *filename)
  23. {
  24. char    *buffer;
  25. int    length;
  26.  
  27. if ( !File_Exists( filename))    return NULL;
  28.  
  29. File_GetLength( filename, &length);
  30.  
  31. buffer = malloc( 1+length);
  32. if ( !buffer)    return NULL;
  33.  
  34. if ( File_LoadTo( filename, buffer, NULL))    {
  35.     free( buffer);
  36.     return NULL;
  37.     }
  38.  
  39. buffer[ length] = 0;
  40.  
  41. return buffer;
  42. }
  43.  
  44.